<?php
namespace app\common\model;

use think\Model;

class City extends Model   //model层 从数据库查询数据
{
    //根据parent_id获取二级城市
	public function getNormalCitysByParentId($parentId = 0){
		 $data = [
		      'status' => 1,
			  'parent_id' => $parentId,		  
		  ];
		  $order = [
		      'id' => 'desc',
		  ];
		  return $this -> where($data)
		               ->order($order)
				       ->select();
		
		}

//获取所有二级城市
        public function getNormalCitys(){
		 $data = [
		      'status' => 1,
			  'parent_id' => ['gt', 0],		  
		  ];
		  $order = [
		      'id' => 'desc',
		  ];
		  return $this -> where($data)
		               ->order($order)
				       ->select();
		
		}




public function getCityById($id){

       $data = [
		      'status' => 1,
			  'id' => $id,		  
		  ];

		  return $this-> where($data)->select();
}


}
?>